package mo.leetcode_top;

import mo.common.TreeNode;

import java.util.ArrayList;
import java.util.List;

public class L94 {

    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> result = new ArrayList<>();
        helper(root, result);
        return result;
    }

    private void helper(TreeNode node, List<Integer> result) {
        if (node != null) {
            if (node.left != null) {
                helper(node.left, result);
            }
            result.add(node.val);
            if (node.right != null) {
                helper(node.right, result);
            }
        }
    }

}
